package metier.sess;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import metier.entities.Etat;


@Stateless(name="Etat")
public class EtatEJBImpl implements IEtatLocal,IEtatRemote{
	
	@PersistenceContext(unitName="PU_Cargaison")
	private EntityManager em;

	@Override
	public void addEtat(Etat e) {
		em.merge(e);
		
	}

	@Override
	public List<Etat> getAllEtats() {
		
		Query req=em.createQuery("select e from Etat e");
		return req.getResultList();
		
	}
	
	

	@Override
	public Etat getEtat(Integer Id) {
		Etat e=em.find(Etat.class, Id);
		return e;
	}

	@Override
	public void updateEtat(Etat etat) {
		em.merge(etat);
		
	}

	@Override
	public void deleteEtat(Integer Id) {
		
		Etat e=getEtat(Id);
		em.remove(e);
		
	}
	
	

}
